package com.ccb.cloud.rca.appservice.service.assetsupervise.impl;


import com.ccb.cloud.rca.appservice.aopTest.MyAop;
import com.ccb.cloud.rca.appservice.dao.DO.assetsupervise.User;
import com.ccb.cloud.rca.appservice.dao.mapper.assetsupervise.UserMapper;
import com.ccb.cloud.rca.appservice.dto.ReqPaginationBase;
import com.ccb.cloud.rca.appservice.dto.assetsupervise.UserQueryDTO;
import com.ccb.cloud.rca.appservice.service.assetsupervise.UserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/**
 * @author wang
 * @Description Index
 * @create 2021-09-13 11:57
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    /**
     * 查询列表
     * @param user
     * @return
     */
    @Override
    public List<User> findList(User user) {
        return userMapper.findList(user);
    }

    /**
     * 添加对象
     * @param user
     */
    @Override
    public void addObject(User user) {
        userMapper.insert(user);
    }

    /**
     * 修改对象
     * @param user
     */
    @Override
    public void updateObject(User user) {
        userMapper.update(user);
    }

    /**
     * 删除对象
     * @param user
     */
    @Override
    public void deleteObject(User user) {
        userMapper.delete(user);
    }

    /**
     * 查询一条
     * @param user
     * @return
     */
    @Override
    @MyAop
    public User findOne(User user) {
        System.out.println("我在方法里");
        return userMapper.findOne(user);
    }

    /**
     * 分页查询
     * @param userDto
     * @return
     */
    @Override
    public PageInfo<User> findPage(ReqPaginationBase<UserQueryDTO> userDto) {
        UserQueryDTO data = userDto.getData();
        PageHelper.startPage(userDto.getPageNum(), userDto.getPageSize());
        User user = new User();
        BeanUtils.copyProperties(user,userDto);
        PageInfo<User> userPageInfo = new PageInfo<User>(this.findList(user));
        return userPageInfo;
    }
}
